<?php

require_once __DIR__ . '/../bean/Turno.php';
require_once __DIR__ . '/abstract/AbstractDAO.php';

/**
 * DAO para abstração de acesso a informações sobre turno.
 *
 * @author hyzandey
 */
class TurnoDAO extends AbstractDAO {

    const SELECT_REGULAR = 'select * from turno_regular order by turno';
    const SELECT_EJA = 'select * from turno_eja order by turno';

    private $isEja;

    public function __construct($isEja) {
        parent::__construct();
        $this->eja = $isEja;
    }

    public function find() {
        $this->query = $this->isEja ? self::SELECT_EJA : self::SELECT_REGULAR;

        $this->executaQuery();

        $turnoList = array();

        while ($row = $this->proximaLinhaResultado()) {
            $turnoList[] = new Turno($row['turno']);
        }

        return $turnoList;
    }

}

?>
